package com.xhh.nphm.system.service.impl;

import com.xhh.nphm.system.mapper.CommonDao;
import com.xhh.nphm.system.mapper.SysUserLoginSateDao;
import com.xhh.nphm.system.service.SysUserLoginStateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Program: hw-zhuanban
 * @ClassName SysUserLoginStateServiceImpl
 * @Author: liutao
 * @Description: 下级部门登录详情接口实现类
 * @Create: 2022-08-09 15:12
 * @Version 1.0
 **/
@Service
public class SysUserLoginStateServiceImpl implements SysUserLoginStateService {
    @Autowired
    private SysUserLoginSateDao sysUserLoginSateDao;

    @Autowired
    private CommonDao commonDao;

    @Override
    public List<Map> loginState(Long deptParentId) {
        String s = deptParentId.toString();
        //查询下级部门 304040 → 301040
        if (s.length()>3&&s.startsWith("304")){
            s = "301"+s.substring(3,6);
        }
        return sysUserLoginSateDao.loginState(s);
    }

    @Override
    public int areaAllCount(Long deptParentId) {
        return sysUserLoginSateDao.areaAllCount(deptParentId);
    }

    @Override
    public int areaOnlineCount(Long deptParentId) {
        return sysUserLoginSateDao.areaOnlineCount(deptParentId);
    }

    @Override
    public List<Map> findDeptNameOrUserNum(Long deptId) {
        return commonDao.findDeptNameOrUserNum(String.valueOf(deptId));
    }
}
